home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-glow-button.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  4.8 KB  |  158 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Alien Glow themed button
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ; based on code from Frederico Mena Quintero (Quartic)
  8. ; federico@nuclecu.unam.mx
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ; This program is distributed in the hope that it will be useful,
  15. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ; GNU General Public License for more details.
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. (define (text-width extents)
  24.   (car extents))
  25.  
  26. (define (text-height extents)
  27.   (cadr extents))
  28.  
  29. (define (text-ascent extents)
  30.   (caddr extents))
  31.  
  32. (define (text-descent extents)
  33.   (cadr (cddr extents)))
  34.  
  35. (define (blend-bumpmap img
  36.                drawable
  37.                x1
  38.                y1
  39.                x2
  40.                y2)
  41.   (gimp-edit-blend drawable FG-BG-RGB-MODE DARKEN-ONLY-MODE
  42.            GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  43.            FALSE 0 0 TRUE
  44.            x1 y1 x2 y2))
  45.  
  46. (define (script-fu-alien-glow-button text
  47.                      font
  48.                      size
  49.                      text-color
  50.                      glow-color
  51.                      bg-color
  52.                      padding
  53.                      glow-radius
  54.                      flatten)
  55.   (let* ((text-extents (gimp-text-get-extents-fontname text
  56.                                size
  57.                                PIXELS
  58.                                font))
  59.      (ascent (text-ascent text-extents))
  60.      (descent (text-descent text-extents))
  61.      
  62.      (img-width (+ (* 2  padding)
  63.                (text-width text-extents)))
  64.      (img-height (+ (* 2 padding)
  65.             (+ ascent descent)))
  66.      (layer-height img-height)
  67.      (layer-width img-width)
  68.      (img-width (+ img-width glow-radius))
  69.      (img-height (+ img-height glow-radius))
  70.      (img (car (gimp-image-new  img-width   img-height  RGB)))
  71.      (bg-layer (car (gimp-layer-new img
  72.                     img-width img-height RGBA-IMAGE
  73.                     "Background" 100 NORMAL-MODE)))
  74.      (glow-layer (car (gimp-layer-new img
  75.                       img-width img-height RGBA-IMAGE
  76.                       "Glow" 100 NORMAL-MODE)))
  77.      (button-layer (car (gimp-layer-new img
  78.                         layer-width layer-height RGBA-IMAGE
  79.                         "Button" 100 NORMAL-MODE))))
  80.  
  81.     (gimp-context-push)
  82.  
  83.     (gimp-image-undo-disable img)
  84.  
  85.     ; Create bumpmap layer
  86.     
  87.     (gimp-image-add-layer img bg-layer -1)
  88.     (gimp-context-set-foreground '(0 0 0))
  89.     (gimp-context-set-background bg-color)
  90.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  91.     (gimp-image-add-layer img glow-layer -1)
  92.  
  93.     ; Create text layer
  94.  
  95.     (gimp-image-add-layer img button-layer -1)
  96.     (gimp-layer-set-offsets button-layer (/ glow-radius 2) (/ glow-radius 2))
  97.     (gimp-selection-none img)
  98.     (gimp-rect-select img 0 0 img-width img-height CHANNEL-OP-REPLACE FALSE 0)
  99.     (gimp-context-set-foreground '(100 100 100))
  100.     (gimp-context-set-background '(0 0 0))
  101.  
  102.     (gimp-edit-blend button-layer FG-BG-RGB-MODE NORMAL-MODE
  103.              GRADIENT-SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE
  104.              FALSE 0 0 TRUE
  105.              0 0 img-height img-width)
  106.  
  107.     (gimp-edit-clear glow-layer)
  108.  
  109.     (gimp-rect-select img
  110.               (/ glow-radius 4)
  111.               (/ glow-radius 4)
  112.               (- img-width (/ glow-radius 2))
  113.               (- img-height (/ glow-radius 2))
  114.               CHANNEL-OP-REPLACE FALSE 0 )
  115.  
  116.     (gimp-context-set-foreground glow-color)
  117.     (gimp-edit-fill glow-layer FOREGROUND-FILL)
  118.     (gimp-selection-none img)
  119.     (plug-in-gauss-rle 1 img glow-layer glow-radius TRUE TRUE)
  120.     (gimp-context-set-foreground text-color)
  121.     (let ((textl (car (gimp-text-fontname
  122.                img -1 0 0 text 0 TRUE size PIXELS font))))
  123.       (gimp-layer-set-offsets textl
  124.                   (+  padding (/ glow-radius 2))
  125.                   (+ (+ padding descent) (/ glow-radius 2))))
  126.     ; Done
  127.     (gimp-selection-none img)
  128.     (gimp-image-undo-enable img)
  129.     (if (= flatten TRUE)
  130.     (gimp-image-flatten img))
  131.  
  132.     (gimp-display-new img)
  133.  
  134.     (gimp-context-pop)))
  135.  
  136. (script-fu-register "script-fu-alien-glow-button"
  137.             _"B_utton..."
  138.             "Button with an eerie glow"
  139.             "Adrian Likins"
  140.             "Adrian Likins"
  141.             "July 1997"
  142.             ""
  143.             SF-STRING     _"Text"               "Hello world!"
  144.             SF-FONT       _"Font"               "Sans Bold"
  145.             SF-ADJUSTMENT _"Font size (pixels)" '(22 2 100 1 1 0 1)
  146.             SF-COLOR      _"Text color"         '(0 0 0)
  147.             SF-COLOR      _"Glow color"         '(63 252 0)
  148.             SF-COLOR      _"Background color"   '(0 0 0)
  149.             SF-ADJUSTMENT _"Padding"            '(6 1 100 1 10 0 1)
  150.             SF-ADJUSTMENT _"Glow radius"        '(10 1 200 1 10 0 1)
  151.             SF-TOGGLE     _"Flatten image"      TRUE)
  152.  
  153. (script-fu-menu-register "script-fu-alien-glow-button"
  154.              _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Alien Glow")
  155.